#ifndef FRAMEBUFFEROBJECT_H
#define FRAMEBUFFEROBJECT_H

#include "bga/graphics/Texture2D.h"
#include "bga/graphics/RenderBufferObject.h"

#include <map>

/**
 * \namespace bga
 * \brief API namespace
 */
namespace bga
{

/*! \class FrameBufferObject
*   \brief Class which contains OpenGL FBO operations
*/
class BOARD_HELL_ENGINE FrameBufferObject : public GLObject
{
    public:
        FrameBufferObject();

        virtual ~FrameBufferObject();

        /*!
         * \brief Bind the FBO
         */
        virtual void bind() const;

        /*!
         * \brief Unbind the FBO
         */
        virtual void unbind() const;

        /*!
         * \brief Attach a 2D texture to the FBO at given attachment point
         */
        void attachTexture2D(GLenum attachment, Texture2D* texture2d);

        /*!
         * \brief Apply the specified attachement
         */
        void applyAttachment();

    private:
        bool isValid();

        virtual GLuint generate() const;

        std::map<GLenum, Texture2D*> texture2dAttachment;

        RenderBufferObject rbo;
};

}

#endif // FRAMEBUFFEROBJECT_H
